<?php

namespace App\Http\Middleware;

use Closure;

class IsLogin
{
    /**
     * Handle an incoming request.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  \Closure  $next
     * @return mixed
     */
    public function handle($request, Closure $next)
    {
        // 如果用户登录了就放行,如果用户没有登录,返回登录页面
        if(session('user')){

          // $route = \Route::current()->getActionName();
          $routes = \Route::current()->getActionName();

          $qx = session('perm');
          // dd($qx);
          if(in_array($routes,$qx)){

              return redirect('noauth');
          }else{
       
               return $next($request);

          }
          // echo \Route::current()->getActionName();
      }else{
          return redirect('admin/login');
      }
        
    }

    

}
